#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_read_input_to_file.py
# author:张世航
# datetime:2024/11/9 17:43
# software: PyCharm
"""
this is function  description 
"""
# import module your need


# 1 写一个程序，读取键盘输入的任意行文字信息，当输入空行时结束输入，将读入的字符串存于列表;然后将列表里面的内容写入到文件input.txt中；

# 1. 读取键盘输入的任意行文字信息，直到输入空行
def read_input_to_file():
    try:
        lines = []
        while True:
            line = input("请输入内容（空行结束）：")
            if line == "":
                break
            lines.append(line)

        # 将列表内容写入到文件input.txt中
        with open("input.txt", "w", encoding="utf-8") as file:
            for line in lines:
                file.write(line + "\n")
        print("内容已写入input.txt")
    except Exception as e:
        print(f"发生错误: {e}")

read_input_to_file()